public class PlayerStats 
{ 
	private String _name;
	private int _gamesWon = 0;
	private int _gamesLost = 0;
	private int _gamesTied = 0;
	private int _squaresWon = 0;
	private long _totalMillis = 0;
	private long _gameMillis = 0;
	private long _start = 0;
	
	public PlayerStats(String name)
	{
		_name = name;
	}
	
	public String toString()
	{
		String record = "(" + _gamesWon + "-" + _gamesLost;
		if (_gamesTied > 0)
			record += "-" + _gamesTied;
		record += ")";
		String time = Long.toString(_totalMillis/1000) + "."
			+ Long.toString(_totalMillis % 1000);
		return _name + " " + record + " [" + _squaresWon + "] {" + time + " seconds}";
	}
	
	public void addStats(int squares, int mostSquares, boolean tie)
	{
		_totalMillis += _gameMillis;
		_gameMillis = 0;
		_squaresWon += squares;
		if (squares < mostSquares)
			_gamesLost++;
		else if (tie)
			_gamesTied++;
		else
			_gamesWon++;
		
	}
	
	public void startTurn()
	{
		_start = System.currentTimeMillis();
	}
	
	public void endTurn()
	{
		long end = System.currentTimeMillis();
		long spent = end - _start;
		_gameMillis += spent;
	}
} 
